import {createStore, applyMiddleware,compose} from 'redux';
import reduxLogger from 'redux-logger';
import reduxThunk from 'redux-thunk';
import reduxPromise from 'redux-promise';
import reducer from './reducer/index';
import {routerMiddleware} from 'react-router-redux';

let createHistory = require('history').createHashHistory;
let history = createHistory();   // 初始化history
let routerWare = routerMiddleware(history);
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;


/*
 * REDUX中间件
 *   redux-logger：能够在控制台清晰的展示出当前REDUX操作的流程和信息(原有状态、派发信息、修改后的状态信息)
 *
 *   redux-thunk：处理异步的DISPATCH派发
 *
 *   redux-promise：在DISPATCH派发的时候支持PROMISE操作
 */

let store = createStore(reducer,composeEnhancers(applyMiddleware(reduxLogger,reduxPromise,reduxThunk,routerWare)));
export default store